<?php

include_once($GLOBALS['cfgPaths']['lib'].'cms/shop/PostageCalculator.o.inc.php');

class StdAmountPostageCalculator extends PostageCalculator
{
    
    function calc($om, $id) 
    {
        $sth = $GLOBALS['udba']->query("select max(amount) from ".$GLOBALS['udba']->tableforwarder.
            "_shopSupplierProgRate where supplier_id='".$id.
            "' and amount <= ".$om->totalPrice());
        if (is_object($sth))
        {
            $row = $sth->fetch_row();
            $sth = $GLOBALS['udba']->query("select cost from ".$GLOBALS['udba']->tableforwarder.
            "_shopSupplierProgRate where supplier_id = '".$id.
            "' and amount = ".$row[0]);
            if (is_object($sth))
            {
                $row2 = $sth->fetch_row();
                return array('cost' => $row2[0], 'amount' => $row[0]);
            }
        }
    }
    
}

?>